import React from 'react'

function RefHook() {
    const [input, setInput] = React.useState('')
    const inputRef = React.useRef()
    const changeEvent = () => {
        setInput(input => input = inputRef.current.value)
    }
    return (
        <div className="container" style={{padding:'40px',backgroundColor:'green',marginBottom:'20px'}}>
            <h4 className='display-4'>当前输入值为<strong className='text text-danger'>{input}</strong></h4>
            <input ref={inputRef} onChange={changeEvent} className='form-control' type="text"/>
        </div>
    )
}

export default RefHook